<?php

namespace app\common\model\Project;

use think\Model;

class Order extends Model{
    protected $table='pre_project_order';

    protected $autoWriteTimestamp=true;

    protected $createTime='createtime';

    protected $updateTime=false;

    protected $append=[
        "status_text",
    ];

    public function getStatusTextAttr($value,$data){
        $status=$data['status'];
        $text='';

        switch($status){
            case 0:
                $text='未接单';
                break;
            case 1:
                $text='已接单';
                break;
            case 2:
                $text='已支付';
                break;
            case 3:
                $text='已完成';
                break;
            case -1:
                $text='撤销服务';
                break;
            default:
                $text='未知状态';
                break;
        }

        return $text;
    }

    public function project(){
        return $this->belongsTo('app\common\model\Project\Project','Projectid','id',[],'LEFT')->setEagerlyType(0);
    }
}